<?php

/*
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
*/

// Get variables
$app = get_input('client_id');
$userid = get_input('user_id');

if(!$userid)
    $userid = get_loggedin_userid();

$drawings = array();

$drawing_ids = get_favorite_drawing_ids($userid);
//print_r($drawing_ids);
foreach($drawing_ids as $drawing_id) {
    $drawings[] = to_drawing_array(get_drawing_by_id($drawing_id->favorite_id));
}

echo json_encode(export_result(200, $drawings));

?>